home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: August 26, 1998
- // Author: cdt
- //
- // Description:
- //
- // Input Arguments:
- //
- // Return Value:
- //
-
- global proc animExportSetup(string $nextOptions[])
- //
- // Description:
- // Takes a string array containing an option keyword and its argument.
- // This is used to set the copyKey widgets.
- //
- {
- string $kCopyKeyWhichRange = "whichRange";
- string $kCopyKeyRange = "range";
- string $kCopyKeyOptions = "options";
- string $kCopyKeyHierarchy = "hierarchy";
- string $kCopyKeyControlPoints = "controlPoints";
- string $kCopyKeyShapes = "shapes";
- string $kCopyKeyHelpPictures = "helpPictures";
- string $kCopyKeyUseChannelBox = "useChannelBox";
-
- if ($nextOptions[0] == $kCopyKeyWhichRange) {
- // time range
- //
- int $timeRange = $nextOptions[1];
- radioButtonGrp
- -edit
- -select $timeRange
- timeRange;
- } else if ($nextOptions[0] == $kCopyKeyRange) {
- // start/end times
- //
- string $time = $nextOptions[1];
- string $range[];
- tokenize ($time, ":", $range);
- float $start = float ($range[0]);
- float $end = float ($range[1]);
- floatFieldGrp -edit -value1 $start frameStart;
- floatFieldGrp -edit -value1 $end frameEnd;
- } else if ($nextOptions[0] == $kCopyKeyOptions) {
- // -option
- //
- string $option = $nextOptions[1];
- if ($option == "keys") {
- radioButtonGrp
- -edit
- -select 1
- method;
- }
- else {
- radioButtonGrp
- -edit
- -select 2
- method;
- }
- } else if ($nextOptions[0] == $kCopyKeyHierarchy) {
- // -hierarchy
- //
- string $hierarchy = $nextOptions[1];
- if ($hierarchy == "below") {
- radioButtonGrp
- -edit
- -select 2
- hierarchy;
- }
- else {
- radioButtonGrp
- -edit
- -select 1
- hierarchy;
- }
- } else if ($nextOptions[0] == $kCopyKeyControlPoints) {
- // -controlPoints
- //
- int $controlPoints = $nextOptions[1];
- checkBoxGrp -e -value1 $controlPoints controlPoints;
- } else if ($nextOptions[0] == $kCopyKeyShapes) {
- // -shape
- //
- int $shapes = $nextOptions[1];
- checkBoxGrp -e -value1 $shapes shapes;
- } else if ($nextOptions[0] == $kCopyKeyHelpPictures) {
- // help images
- //
- int $pictures = $nextOptions[1];
- checkBoxGrp -e -value1 $pictures helpPictures;
- } else if ($nextOptions[0] == $kCopyKeyUseChannelBox) {
- // use channel box attrs
- //
- int $boxAttrs = $nextOptions[1];
- radioButtonGrp -e -select ( $boxAttrs + 1 ) channels;
- if( $boxAttrs ) {
- frameLayout -e -collapse yes attributesFrame;
- } else {
- frameLayout -e -collapse no attributesFrame;
- }
- }
-
- // Now get all the dependent widgets in the right
- // enabled/disabled/collapsed/expanded state
- //
- animExportWidgetsEnable;
- animExportHelpPictures;
- }
-
- global proc string animExportGetOpts()
- //
- // Description:
- // Sets the opts string for all of the copyKey options.
- //
- {
- string $opts;
- string $kCopyKeyWhichRange = "whichRange";
- string $kCopyKeyRange = "range";
- string $kCopyKeyOptions = "options";
- string $kCopyKeyHierarchy = "hierarchy";
- string $kCopyKeyControlPoints = "controlPoints";
- string $kCopyKeyShapes = "shapes";
- string $kCopyKeyHelpPictures = "helpPictures";
- string $kCopyKeyUseChannelBox = "useChannelBox";
-
- // which time range
- //
- int $whichRange = `radioButtonGrp -q -select timeRange`;
- $opts += (";" + $kCopyKeyWhichRange + "=" + $whichRange);
-
- // -time
- //
- string $timeRange =
- string (`floatFieldGrp -query -value1 frameStart`) + ":" +
- string (`floatFieldGrp -query -value1 frameEnd`);
- $opts += (";" + $kCopyKeyRange + "=" + $timeRange);
-
- // -option
- //
- string $option;
- if (`radioButtonGrp -query -select method` == 1) {
- $option = "keys";
- }
- else {
- $option = "curve";
- }
- $opts += (";" + $kCopyKeyOptions + "=" + $option);
-
- // -hierarchy
- //
- string $hierarchy;
- int $selected = `radioButtonGrp -query -select hierarchy`;
- if ($selected == 2) {
- $hierarchy = "below";
- }
- else {
- $hierarchy = "none";
- }
- $opts += (";" + $kCopyKeyHierarchy + "=" + $hierarchy);
-
- // -controlPoints
- //
- int $doControlPoints = `checkBoxGrp -query -value1 controlPoints`;
- $opts += (";" + $kCopyKeyControlPoints + "=" + $doControlPoints);
-
- // -shapes
- //
- int $doShapes = `checkBoxGrp -query -value1 shapes`;
- $opts += (";" + $kCopyKeyShapes + "=" + $doShapes);
-
- // help
- //
- int $helpPictures = `checkBoxGrp -query -value1 helpPictures`;
- $opts += (";" + $kCopyKeyHelpPictures + "=" + $helpPictures);
-
- // use channel box attrs
- //
- int $useChannelBox = `radioButtonGrp -query -select channels`;
- $useChannelBox--;
- $opts += (";" + $kCopyKeyUseChannelBox + "=" + $useChannelBox);
-
- // Since the copyKey command is fairly complex to assemble, the string
- // passed to AnimExport will be long. The first section is the
- // options in the option box. The second section is the copyKey command
- // without the -cb api call.
- //
- // Effectively these contain the same data, but the two formats are
- // needed to make parsing easier.
- //
- string $cmd = "copyKeyCmd=";
- $cmd = $cmd + "-animation objects ";
-
- // Now assemble the options into a string to pass to animExport.
- // The > character will be replaced by a quotation mark in the
- // AnimExport plug-in. This is required, since the translator option
- // box does not handle escaped quotation marks.
- //
- if ($whichRange == 2) {
- $cmd = ( $cmd + "-time >" + $timeRange + "> ");
- $cmd = ( $cmd + "-float >" + $timeRange + "> ");
- }
-
- // If there's a time specified, always add the option
- //
- $cmd = ( $cmd + "-option " + $option + " " );
-
- if ($useChannelBox == 1) {
- string $main[];
- string $shape[];
- string $history[];
- int $i;
- string $attrs;
-
- catch( $main = `channelBox -q -sma mainChannelBox` );
- catch( $shape = `channelBox -q -ssa mainChannelBox` );
- catch( $history = `channelBox -q -sha mainChannelBox` );
-
- for( $i = 0; $i < size( $main ); $i++ ) {
- $attrs = ( $attrs + "-at " + $main[$i] + " " );
- }
- for( $i = 0; $i < size( $shape ); $i++ ) {
- $attrs = ( $attrs + "-at " + $shape[$i] + " " );
- }
- for( $i = 0; $i < size( $history ); $i++ ) {
- $attrs = ( $attrs + "-at " + $history[$i] + " " );
- }
-
- if( size( $attrs ) == 0 ) {
- $cmd = "";
- warning( "No channels selected in channel box" );
- } else {
- $cmd = ( $cmd +
- $attrs +
- "-hierarchy " + $hierarchy + " " );
- }
-
- // Now add the specific objects from the channel box
- //
- string $objList[] = `channelBox -q -mainObjectList mainChannelBox`;
- if ((size($main) > 0) && (size($objList) > 0))
- {
- for ($object in $objList)
- $cmd = $cmd + " " + $object;
- }
- $objList = `channelBox -q -shapeObjectList mainChannelBox`;
- if ((size($shape) > 0) && (size($objList) > 0))
- {
- for ($object in $objList)
- $cmd = $cmd + " " + $object;
- }
- $objList = `channelBox -q -historyObjectList mainChannelBox`;
- if ((size($history) > 0) && (size($objList) > 0))
- {
- for ($object in $objList)
- $cmd = $cmd + " " + $object;
- }
- } else {
- $cmd = ($cmd +
- "-hierarchy " + $hierarchy + " " +
- "-controlPoints " + $doControlPoints + " " +
- "-shape " + $doShapes + " " );
- }
-
- $opts += ";" + $cmd;
-
- return $opts;
- }
-
- global proc animExportHelpPictures() {
- int $doPictures = `checkBoxGrp -q -value1 helpPictures`;
- if( $doPictures == 0 ) {
- frameLayout -e -collapse yes methodPictureFrame;
- return;
- }
-
- int $method = `radioButtonGrp -q -select method`;
-
- string $methodPicture;
-
- if( $method == 1 ) {
- $methodPicture = "CCPkeyframesOnly.xpm";
- } else {
- $methodPicture = "CCPcurveExact.xpm";
- }
-
- picture -e -image $methodPicture methodPicture;
- frameLayout -e -collapse no methodPictureFrame;
- }
-
- global proc animExportWidgetsEnable()
- //
- // Description:
- // These are the widgets that get enabled and
- // disabled based on the certain states. Put them
- // here so they're all in one place.
- //
- {
- // Shapes and CVs checkboxes
- //
- int $enableIt = (( `radioButtonGrp -q -select channels` == 1 ) &&
- ( `radioButtonGrp -q -enable channels` ));
- frameLayout -e -enable $enableIt attributesFrame;
-
-
- // Start/End fields
- //
- $enableIt = (( `radioButtonGrp -q -select timeRange` == 2 ) &&
- ( `radioButtonGrp -q -enable timeRange` ));
- frameLayout -e -enable $enableIt startEndFrame;
- }
-
- proc string animExportWidgets( string $tabLayout)
- {
- global int $gTextColumnWidthIndex;
-
- setParent $tabLayout;
-
- string $tabForm = `columnLayout -adjustableColumn true`;
-
- frameLayout -bv no -lv no -collapsable yes -collapse false
- hierChanAttrFrame;
-
- columnLayout -adjustableColumn true;
- radioButtonGrp
- -numberOfRadioButtons 2
- -label "Hierarchy"
- -label1 "Selected"
- -label2 "Below"
- -enable true
- hierarchy;
-
- radioButtonGrp
- -numberOfRadioButtons 2 -label "Channels"
- -label1 "All Keyable"
- -cc1 "animExportWidgetsEnable"
- -label2 "From Channel Box"
- -cc2 "animExportWidgetsEnable"
- -enable true
- channels;
-
- frameLayout -bv no -lv no -collapsable no attributesFrame;
- columnLayout -adjustableColumn true;
- checkBoxGrp -label "Control Points"
- -ncb 1 -value1 off -l1 ""
- controlPoints;
- checkBoxGrp -label "Shapes" -ncb 1
- -value1 on -l1 "" shapes;
- setParent ..;
- setParent ..;
-
- separator -style "in" -w 1000;
- setParent ..;
- setParent ..;
-
- radioButtonGrp -numberOfRadioButtons 2 -label "Time Range"
- -label1 "All"
- -cc1 "animExportWidgetsEnable"
- -label2 "Start/End"
- -cc2 "animExportWidgetsEnable"
- timeRange;
-
- frameLayout -bv no -lv no -collapsable no startEndFrame;
- columnLayout -adjustableColumn true;
- floatFieldGrp -label "Start Time" -value1 0.0 frameStart;
- floatFieldGrp -label "End Time" -value1 10.0 frameEnd;
-
- separator -style "in" -w 1000;
-
- checkBoxGrp -label "Help Images" -ncb 1 -value1 off -l1 ""
- -cc1 "animExportHelpPictures;"
- helpPictures;
-
- radioButtonGrp -numberOfRadioButtons 2 -label "Method"
- -label1 "Keys" -cc1 "animExportHelpPictures"
- -label2 "Segments" -cc2 "animExportHelpPictures" method;
-
- frameLayout -bv no -lv no -collapsable yes -collapse yes
- methodPictureFrame;
- columnLayout -columnAttach "left" $gTextColumnWidthIndex;
- picture methodPicture;
- setParent ..;
- setParent ..;
-
- setParent ..;
- setParent ..;
-
- return $tabForm;
- }
-
- global proc int animExportOptions( string $parent,
- string $action,
- string $initialSettings,
- string $resultCallback )
- //
- // Description:
- // This script posts the anim export options.
- //
- // Parameters:
- // $parent - the elf parent layout for this options layout. It is
- // always a scrollLayout.
- // $action - the action that is to be performed with this invokation
- // of this proc. Valid options are:
- // "query" - construct the options string and pass it
- // to the resultCallback.
- // "post" - post all the elf controls.
- // $resultCallback -
- // This is the proc to be called with the result string.
- // resultCallback ( string $optionsString )
- //
- // Returns:
- // 1 if successfull.
- // 0 otherwise.
- //
- {
- int $result;
- string $currentOptions;
- string $optionList[];
- string $optionBreakDown[];
- int $index;
-
- optionVar -intValue animExportAnimationFile true;
-
- if ($action == "post") {
- setUITemplate -pushTemplate DefaultTemplate;
- setParent $parent;
-
- columnLayout animExportMultiObjLayout;
-
- // Make the layout invisible during the control creation.
- //
- columnLayout -e -vis false animExportMultiObjLayout;
-
- formLayout animExportForm;
- rowColumnLayout -numberOfColumns 2
- -rat 1 "top" 5
- -cal 1 "right" -cw 2 250 animExportFileOptsLayout;
-
- text -l "Precision";
-
- rowColumnLayout -numberOfColumns 2;
-
- radioCollection animExportCollection;
- radioButton -label "Float (8)"
- -align "left"
- -cl animExportCollection animExportFloatBtn;
-
- text -l "";
-
- radioButton -label "Double (17)"
- -align "left"
- -cl animExportCollection animExportDoubleBtn;
-
- text -l "";
-
- radioButton -label "Custom" -align "left"
- -onc "intField -e -en true animExportIntFld"
- -ofc "intField -e -en false animExportIntFld"
- -cl animExportCollection
- animExportCustomBtn;
-
- intField -min 1 -max 17
- -s 1 -v 17 -en false animExportIntFld;
- setParent ..;
-
- text -l "File Contents";
-
- checkBox -label "Use Node And Leaf Attribute Names"
- -v off animExportNodeChk;
-
- text -l "";
-
- checkBox -label "Verbose Units" -align "left"
- -v off animExportVerboseChk;
-
- setParent ..;
-
- separator -style "in" -w 1000 animExportSep;
-
- formLayout -edit
- -attachForm animExportFileOptsLayout "top" 10
- -attachForm animExportFileOptsLayout "left" 65
-
- -attachControl animExportSep "top" 5 animExportFileOptsLayout
- -attachForm animExportSep "left" 0
- -attachForm animExportSep "right" 0
- animExportForm;
-
- string $copyKeyTab = animExportWidgets("animExportMultiObjLayout");
-
- setParent ..;
-
- setUITemplate -popTemplate;
-
- // Now to set the current settings.
- //
- $currentOptions = $initialSettings;
- if (size($currentOptions) > 0) {
- tokenize($currentOptions, ";", $optionList);
- for ($index = 0; $index < size($optionList); $index++) {
- tokenize($optionList[$index], "=", $optionBreakDown);
-
- if ($optionBreakDown[0] == "intValue") {
- int $intValue = $optionBreakDown[1];
- intField -edit -value $intValue animExportIntFld;
- } else if ($optionBreakDown[0] == "precision") {
- int $precision = $optionBreakDown[1];
-
- if ($precision == 8) {
- radioCollection -edit -select animExportFloatBtn
- animExportCollection;
- } else if ($precision == 17) {
- radioCollection -edit -select animExportDoubleBtn
- animExportCollection;
- } else {
- radioCollection -edit -select animExportCustomBtn
- animExportCollection;
- intField -edit -value $precision animExportIntFld;
- }
- } else if ($optionBreakDown[0] == "nodeNames") {
- int $value = $optionBreakDown[1];
- checkBox -e -v $value animExportNodeChk;
- } else if ($optionBreakDown[0] == "verboseUnits") {
- int $value = $optionBreakDown[1];
- checkBox -e -v $value animExportVerboseChk;
- } else {
- animExportSetup($optionBreakDown);
- }
- }
- }
-
- columnLayout -e -vis true animExportMultiObjLayout;
-
- $result = 1;
- } else if ($action == "query") {
- if (`radioButton -query -sl animExportFloatBtn`) {
- $currentOptions += "precision=8";
- } else if (`radioButton -query -sl animExportDoubleBtn`) {
- $currentOptions += "precision=17";
- } else if (`radioButton -query -sl animExportCustomBtn`) {
- $currentOptions +=
- ("precision=" + `intField -q -value animExportIntFld`);
- }
-
- $currentOptions += (";intValue="+`intField -q -value animExportIntFld`);
- $currentOptions += (";nodeNames="+`checkBox -q -v animExportNodeChk`);
- $currentOptions +=
- (";verboseUnits="+`checkBox -q -v animExportVerboseChk`);
-
- $currentOptions += animExportGetOpts();
-
- eval($resultCallback+" \""+$currentOptions+"\"");
-
- $result = 1;
- } else {
- $result = 0;
- }
-
- return $result;
- }
-